﻿using System;
using System.Globalization;
using Medianamik.Core;
using Medianamik.Core.DAL;
using Medianamik.Core.DAL.Repositories;
using Medianamik.Core.DAL.Services;
using SubSonic;

namespace Medianamik.UI.Web.Shop.Data.Repositories
{
    public class ShoppingCartItemRepository<TCollection, TItem, TModel> : MedianamikRepository<TCollection, TItem>, 
                                                                IShoppingCartItemRepository<TItem, TModel>
        where TItem : Interfaces.IShoppingCartItem<TModel>, IRecordBase, new()
        where TCollection : ICollectionWithChildren<TCollection, TItem>, new()
        where TModel : Interfaces.IModel
    {
        public ShoppingCartItemRepository(ICultureService cultureService, IContentStateService contentStateService, INodeMapper nodeMapper) : base(cultureService, contentStateService, nodeMapper)
        {
        }
    }

    public class ShoppingCartItemRepository :
        ShoppingCartItemRepository<ShoppingCartItemCollection, ShoppingCartItem, Model>, IShoppingCartItemRepository
    {
        public ShoppingCartItemRepository(ICultureService cultureService, IContentStateService contentStateService, INodeMapper nodeMapper)
            : base(cultureService, contentStateService, nodeMapper)
        {
        }

        public override ShoppingCartItem Get(Guid nodeId)
        {
            return Get(nodeId, CultureInfo.InvariantCulture, ContentState.Draft);
        }
    }

    public interface IShoppingCartItemRepository<T, TModel> : IMedianamikRepository<T>
        where T : Interfaces.IShoppingCartItem<TModel>
        where TModel : Interfaces.IModel
    {
    }

    public interface IShoppingCartItemRepository: IShoppingCartItemRepository<ShoppingCartItem, Model>
    {}
}
